package keeto.com.vn.classfied.model;

import java.io.Serializable;

import keeto.com.vn.classified.config.IConstant;


/**
 * 
 * @author hector
 * Created on 2012-9-4<br/>
 * the Roster UI Model, implements Comparable interface to meet the alphabetical sort.
 *
 */
public class RosterUIModel implements Serializable, Comparable<RosterUIModel>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1003869451969685059L;
	
	/**
	 * Mock Presence String for Display
	 */
	public static final String PRESENCE_ONLINE = "Online";
	public static final String PRESENCE_OFFLINE = "Offline";
	public static final String PRESENCE_AWAY = "Away";

	/**
	 * for get Roster from DB
	 */
	private String rosterRemoteId = IConstant.UNINITIALIZED_STRING;

	/**
	 * for judge the Roster is built-in or gateway Roster.
	 */
	private int rosterType = IConstant.UNINITIALIZED_INT;

	private String rosterName = IConstant.UNINITIALIZED_STRING;

	private String displayName = IConstant.UNINITIALIZED_STRING;

	private String statusMessage = IConstant.UNINITIALIZED_STRING;

	private String presence = IConstant.UNINITIALIZED_STRING;
	
	private String userId = IConstant.UNINITIALIZED_STRING;

	/**
	 */
	private long displayPicId = IConstant.UNINITIALIZED_LONG;

	/**
	 */
	private String serviceName = IConstant.UNINITIALIZED_STRING;

	/**
	 * serviceRemoteId is "" that the roster is a build-in roster
	 */
	private String gatewayServiceRemoteId = IConstant.UNINITIALIZED_STRING;
	
	
	private byte[] displayPicture = null;
	
	             
	             // private String supportServiceRemoteId = IConstant.UNINITIALIZED_STRING;

	private long firstMessageId = IConstant.UNINITIALIZED_LONG;
	/**
	 * @category roster type 0 is added from buddylist,1 is added from club
	 * */
	private int specialBuddyType = IConstant.UNINITIALIZED_INT_ZERO;
	
	/*
	 * getters and setters
	 */
	public String getRosterRemoteId() {
		return rosterRemoteId;
	}

	public int getSpecialBuddyType() {
		return specialBuddyType;
	}

	public void setSpecialBuddyType(int specialBuddyType) {
		this.specialBuddyType = specialBuddyType;
	}

	public void setRosterRemoteId(String RosterRemoteId) {
		this.rosterRemoteId = RosterRemoteId;
	}

	public int getRosterType() {
		return rosterType;
	}

	public void setRosterType(int RosterType) {
		this.rosterType = RosterType;
	}

	public String getRosterName() {
		return rosterName;
	}

	public void setRosterName(String RosterName) {
		this.rosterName = RosterName;
	}

	public String getStatusMessage() {
		return statusMessage;
	}

	public void setStatusMessage(String statusMessage) {
		this.statusMessage = statusMessage;
	}

	public String getPresence() {
		return presence;
	}

	public void setPresence(String presence) {
		this.presence = presence;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public String getDisplayName() {
		return displayName;
	}

	public void setGatewayServiceRemoteId(String gatewayServiceRemoteId) {
		this.gatewayServiceRemoteId = gatewayServiceRemoteId;
	}

	public String getGatewayServiceRemoteId() {
		return gatewayServiceRemoteId;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public String getServiceName() {
		return serviceName;
	}
	public void setDisplayPicId(long displayPicId) {
		this.displayPicId = displayPicId;
	}

	public long getDisplayPicId() {
		return displayPicId;
	}
	
	@Override
	public boolean equals(Object o) {
		RosterUIModel newRoster = (RosterUIModel)o;
		try {
		if(!gatewayServiceRemoteId.equals(newRoster.getGatewayServiceRemoteId())||(!rosterRemoteId.equals(newRoster.getRosterRemoteId()))){
			return false;
		}else{
			return true;
		}
		}catch(NullPointerException ex) {
			return false;
		}
	}
	
	public boolean equals(String rosterRemoteId, String gatewayServiceId) {
		if(gatewayServiceRemoteId.equals(gatewayServiceId)&&
				(this.rosterRemoteId.equals(rosterRemoteId))){
			return true;
		}else{
			return false;
		}
	}

	public void setDisplayPicture(byte[] displayPicture) {
		this.displayPicture = displayPicture;
	}

	public byte[] getDisplayPicture() {
		return displayPicture;
	}

	public void setFirstMessageId(long firstMessageId) {
		this.firstMessageId = firstMessageId;
	}

	public long getFirstMessageId() {
		return firstMessageId;
	}

	@Override
	public int compareTo(RosterUIModel another) {
		return displayName.compareToIgnoreCase(another.getDisplayName());
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserId() {
		return userId;
	}

}
